﻿using System.Collections.Generic;
using System.Linq.Expressions;

namespace Entropy.Ext
{
	public class SyntaxTree : ISyntaxTree
	{
		private readonly List<Expression> tree = new List<Expression>();
        private readonly IDictionary<InterfacedFactory, AstConstructor> interfaceFactories = new Dictionary<InterfacedFactory, AstConstructor>();

		Expression[] ISyntaxTree.Result()
		{
            var result = tree.ToArray();
            tree.Clear();
            return result;
        }

		IDictionary<InterfacedFactory, AstConstructor> ISyntaxTree.InterfaceFactories
		{
			get { return interfaceFactories; }
		}

		void ISyntaxTree.Append(Expression expr)
		{
			tree.Add(expr);
		}
    }
}